<?php
function replaceDataUser($data,$oldUser,$newUser)
{
    $newData=array();
    foreach ($data as $key => $value)
    {
        $s=split_code($key);
        $user=$s[0];
        $video=$s[1];
        if($user===$oldUser)
        {
            $_newUser=joint_code($newUser,$video);
            $newData[$_newUser]=$value;
        }
        else
            $newData[$key]=$value;
    }
    return $newData;
}

function modifyUser($userName,$newUser)
{
    $allUser=parse_ini_file('./user.ini');
    if(array_key_exists($userName,$allUser))
    {
        $oldUser=$allUser[$userName];
        $data=parse_ini_file('./data.ini');
        $data=replaceDataUser($data,$oldUser,$newUser);
        write_ini_file('./data.ini',$data);
        $allUser[$userName]=$newUser;
        write_ini_file('./user.ini',$allUser);
        return true;
    }
    else
        return false;
}
